<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/8/17
 * Time: 14:53
 */

error_reporting(0);
use think\facade\Db;
use think\facade\Cache;

//use think\response\Json;
header('Content-Type: text/html;charset=utf-8');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:*');
header("Access-Control-Allow-Headers:DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept-Language, Origin, Accept-Encoding");
header('Access-Control-Allow-Credentials:true');//表示是否允许发送Cookie

function checkRequest()
{
    $time = input('time/d');
    $sign = input('sign/s');
    $randstr = input('randstr/s');
    if(time()-$time>40){
        return ['code'=>101,'msg'=>'请求超时！','data'=>''];
    }
    $str = '';
    for($i=0;$i<10;$i++){
        $str.=$time[$i].$randstr[9-$i];
    }
    if($str!=$sign){
        return ['code'=>102,'msg'=>'签名有误！','data'=>''];
    }
    return ;
}



define('API_HOST',$_SERVER['HTTP_HOST']);//获取当前域名
define('SHUJUCUNCHU',app()->getRootPath().'public');
if(!is_dir(SHUJUCUNCHU)){
    mkdir(SHUJUCUNCHU,0777,true);
}

function apisucess($status, $msg)
{
    $data = ['status' => $status, 'msg' => $msg];
    return json_encode($data);
}




//日期函数
function date_ymd(){
    return date('Y-m-d H:i:s',time());
}

function sp_log($content,$file="log.txt"){
    file_put_contents($file, $content,FILE_APPEND);
}

//  获取13位时间戳
function getMillisecond(){
    list($t1, $t2) = explode(' ', microtime());
    return sprintf('%.0f', (floatval($t1) + floatval($t2)) * 1000);
}






